<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>

<body>
    <script>
        const arr1 = [1, 2, 3, 4, 5];
        const arr2 = [6, 7, 8, 9];

        // 迭代器创建函数  iterator creator
        function* createIterator(arr) {
            for (const item of arr) {
                yield item;
            }
        }

        const iter1 = createIterator(arr1);
        const iter2 = createIterator(arr2);

    </script>
</body>

</html>